<template>
  <view>
    <home :scrollY="scrollY"  :scrollBottom="scrollBottom" :show="tabID==0?true:false" v-if="loadOn.home" @menuTop="menuTops"></home>
    <!--分类-->
    <sort :scrollY="scrollY"  :scrollBottom="scrollBottom" :show="tabID==1?true:false" v-if="loadOn.sort" :sortId="idCur"></sort>
    <!--我的-->
    <my :scrollY="scrollY" :scrollBottom="scrollBottom" :show="tabID==2?true:false" v-if="loadOn.my"/>
    <!--底部导航-->
    <tabbar :tabID='tabID' :msgDot='true' @tabTap='tabTap'/>
  </view>
</template>

<script>
	import home from "../../components/common/home";
  import tabbar from "../../components/common/tabbar";
  import Sort from "../../components/common/sort";
  import my from "../../components/common/my";
  export default {
    components:{
      Sort,
      home,
      tabbar,
      my,
    },
		data() {
			return {
        scrollY: 0,
        tabID: 0,
        scrollBottom: 0,
        loadOn: {
          home: true,
          sort: false,
          my: false
        },
        tabIndex: 0,
        idCur: 0,
			}
		},
		onLoad() {

		},
		methods: {
      tabTap(index) {
        this.tabIndex = this.tabID;
        if (index == 1 && !this.loadOn.sort) {
          this.loadOn.sort = true;
        }
        if (index == 2 && !this.loadOn.my) {
          this.loadOn.my = true;
        }
        this.tabID = index;
        uni.pageScrollTo({
          scrollTop: 0,
          duration: 0
        });
      },
      menuTops(e){
        this.idCur = e.data.id
        this.tabTap(1)
        // console.log(this.idCur)
      },
		},
    onPageScroll(e) {
      this.scrollY = e.scrollTop;
    },
    onReachBottom(e) {
      console.log()
      let timestamp = new Date().getTime();
      this.scrollBottom = timestamp;
    },
	}
</script>

<style>
</style>
